#include<bits/stdc++.h>
using namespace std;
signed main() {
    int aCap, bCap;
    cin >> aCap >> bCap;

    int n;
    cin >> n;

    int ca, cb;
    ca = cb = 0;

    while(n--) {
        if(aCap < ca || bCap < cb) break;

        int a1, a2, b1, b2;
        cin >> a1 >> a2 >> b1 >> b2;

        int sum = a1 + b1;

        if(a2 == sum && b2 != sum) {
            ca++;
        } else if(b2 == sum && a2 != sum) {
            cb++;
        }
    }

    if(aCap < ca) {
        cout << "A\n" << cb;
    } else {
        cout << "B\n" << ca;
    }

    return 0;
}

